package po

import "fmt"

// 定义user结构体 类似于java中的实体类
type User struct {
	ID         int    `json:"id"`
	Phone      string `json:"phone"`
	CreateTime string `json:"create_time"`
	UpdateTime string `json:"update_time"`
	CreateUser string `json:"create_user"`
	UpdateUser string `json:"update_user"`
	Age        int    `json:"age"`
	Birthday   string `json:"birthday"`
	UserName   string `json:"user_name"`
	Password   string `json:"password"`
}

// 构造函数
func NewUser(
	id int,
	phone string,
	age int,
	birthday string,
	createTime string,
	updateTime string,
	createUser string,
	updateUser string,
	username string,
	password string) *User {
	return &User{
		ID:         id,
		Phone:      phone,
		Age:        age,
		Birthday:   birthday,
		CreateTime: createTime,
		UpdateTime: updateTime,
		CreateUser: createUser,
		UpdateUser: updateUser,
		UserName:   username,
		Password:   password}
}

// 重写String方法
func (u *User) String() string {
	return fmt.Sprintf("User:{%d %s %d %s %s %s %s %s %s %s}",
		u.ID, u.Phone, u.Age, u.Birthday, u.CreateTime,
		u.UpdateTime, u.CreateUser, u.UpdateUser, u.UserName, u.Password)
}
